
# A2_import_R
#==============================================================================

# Description: This file splits the data into ~40 parts that are used in the
# estimation. The reason for this split is to save time when sending the codes
# to the server


rm(list=ls(all=TRUE))
setwd("D:/data_replication")   

data_summary<-vector('list',100)

i = 0
i_d = 0
for (k in 1:4300) {
dataset_name <- sprintf("robustness/alt_iv/1_data_format/product_files/data_product_%s.csv", k)
if (file.exists(dataset_name)) {
i = i + 1
dataset = read.csv(dataset_name, header = TRUE)
data_summary[[i]] = dataset
if (i == 100) {
i_d = i_d + 1
data_summary_name <- sprintf("robustness/alt_iv/1_data_format/data_summary_full_%s.RData", i_d)  
save(file = data_summary_name, data_summary)  
data_summary<-vector('list',100)
i = 0
}
}
}

data_summary_name <- sprintf("robustness/alt_iv/1_data_format/data_summary_full_%s.RData", i_d + 1)  
save(file = data_summary_name, data_summary)  

